<?php 
/**
 * Albatross Home Media Streaming Server -- Copyright (c) 2003-2008 Still Designing, LLC
 * Author: David E. Still <stealthdave@stilldesigning.com>
 * Licenced under the GNU General Public License, version 2
 * Name:			haltstream.php
 * Description:	Halt VLC.  This needs to be a seperate executable since streaming locks up index.php
 */

set_time_limit(20);

require_once("albatross.ini.php");

/* Use the vlc http interface to play the "next" stream, which is a quit command */
$halt_stream = "http://".array_shift(explode("\n", file_get_contents('controls/.access')))."@".$_SERVER["SERVER_NAME"].":";
$halt_stream .= (array_key_exists("control_port",$tyini))?$tyini["control_port"]:"8091";
$halt_stream .= "/halt.html?control=next";
$halt = curl_init($halt_stream);
curl_setopt($halt, CURLOPT_TIMEOUT, 2 );
curl_setopt( $halt, CURLOPT_RETURNTRANSFER, false );
if (curl_exec($halt)) echo "Streaming halted.";
else echo "No stream to halt.";
/* Use "kill" command if it's set */
if (array_key_exists("kill", $tyini)) {
	echo "\nRunning kill command... ";
	flush();
	echo shell_exec($tyini["kill"]);
	echo "done.";
}
?>
